#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define MAX_STICK_NUM 64

using namespace std;

int get_min_per_stick_len(int base, int sum)
{

	int min_per_stick_len = base;

	while(sum % min_per_stick_len)
		min_per_stick_len++;

	return min_per_stick_len;
}

bool comp(int a, int b) { return a > b; }

bool validate(int* frag_ary, int frag_num, int stick_len, int sum, int* used, int used_num)
{
	if(sum > stick_len)
		return false;

	if(sum == stick_len)
	{
		if(used_num ==  frag_num)
			return true;

		sum = 0;
	}

	for(int i = 0; i < frag_num; i ++)
	{
		if(used[i])
			continue;
		
		used[i] = 1;
		used_num ++;
		bool b = validate(frag_ary, frag_num, stick_len, sum + frag_ary[i], used, used_num);	

		if(b)
			return true;


		used[i] = 0;
		used_num --;

		if(sum == 0)
			break;

		int j = i + 1;
		while(j < frag_num && frag_ary[i] == frag_ary[j])
			j ++;

		i = j - 1;
	}

	return false;
}

int main(void)
{
	int frag_num; 
	int frag_ary[128];
	while(true)
	{
		scanf("%d", &frag_num);
		if(!frag_num)
			break;

		for(int i = 0; i < frag_num; i ++)
			scanf("%d", &frag_ary[i]);

		sort(frag_ary, frag_ary + frag_num, comp);

		int max = frag_ary[0];
		int sum = 0;
		for(int i = 0; i < frag_num; i ++)
			sum += frag_ary[i];
		int min_per_stick_len = get_min_per_stick_len(max, sum);
		int stick_num = sum / min_per_stick_len;

		map<int, int> harness;
		int used[MAX_STICK_NUM];
		memset(used, 0, sizeof(int) * MAX_STICK_NUM);
		while(!validate(frag_ary, frag_num, min_per_stick_len, 0, used, 0))
		{
			min_per_stick_len = get_min_per_stick_len(min_per_stick_len + 1, sum);
			stick_num = sum / min_per_stick_len;
		}

		printf("%d\n", min_per_stick_len);
	}
	return 0;
}

